﻿using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;

namespace EasyLinkerSDK.Model.Info
{
    public class SdkInfo
    {
        public SdkInfo()
        {
            try
            {
                //获取当前程序集信息
                Assembly asm = Assembly.GetExecutingAssembly();
                AssemblyName assembly = asm.GetName();
                //Other info
                AssemblyDescriptionAttribute asmdis = (AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(asm, typeof(AssemblyDescriptionAttribute));
                AssemblyCopyrightAttribute asmcpr = (AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(asm, typeof(AssemblyCopyrightAttribute));
                AssemblyCompanyAttribute asmcpn = (AssemblyCompanyAttribute)Attribute.GetCustomAttribute(asm, typeof(AssemblyCompanyAttribute));

                this.Name = assembly.Name;
                this.Version = assembly.Version.ToString();
                this.Description = asmdis == null ? string.Empty : asmdis.Description;
                this.Copyright = asmcpr == null ? string.Empty : asmcpr.Copyright;
                this.Company = asmcpn == null ? string.Empty : asmcpn.Company;
                this.Refers = new Dictionary<string, string>()
                {
                    { "GodSharp.Socket","https://github.com/godsharp/GodSharp.Socket"},
                    { "MQTTnet","https://github.com/chkr1011/MQTTnet"},
                    { "Newtonsoft.Json","https://github.com/JamesNK/Newtonsoft.Json"},
                };
            }
            catch
            {

            }
        }

        public string Name { get; set; }

        public string Version { get; set; }

        public string Description { get; set; }

        public string Copyright { get; set; }

        public string Company { get; set; }

        public Dictionary<string, string> Refers { get; set; }
    }
}
